import { useEffect } from "react";
import { useLocation, useNavigate } from "react-router-dom";

const useRouterDown = () => {
  const { pathname } = useLocation();
  const nav = useNavigate();
  const token = localStorage.getItem("token");
  useEffect(() => {
    const whileList = ["/home/order"];
    if (!token && !whileList.includes(pathname)) {
      nav("/login");
    }
  }, [pathname]);
};
export default useRouterDown;
